home *** CD-ROM | disk | FTP | other *** search
/ Teach Your Children: Road Construction Ahead / Teach Your Children: Road Construction Ahead.iso / pc / rca / road.dxr / 00028_Rollover Class.ls < prev    next >
Encoding:
Text File  |  1996-07-17  |  2.6 KB  |  113 lines

  1. property hiliteChan, selectChan, unselectedBitmap, lowestSprite, highestSprite, soundList, soundFlag, soundPath
  2.  
  3. on birth me, low, high, preselected
  4.   set lowestSprite to low
  5.   set highestSprite to high
  6.   set hiliteChan to 0
  7.   set selectChan to low + preselected - 1
  8.   set unselectedBitmap to the castNum of sprite selectChan - 2
  9.   repeat with chan = lowestSprite to highestSprite
  10.     puppetSprite(chan, 1)
  11.   end repeat
  12.   set soundPath to EMPTY
  13.   set soundList to []
  14.   set soundFlag to 0
  15.   return me
  16. end
  17.  
  18. on update me
  19.   doRollovers(me)
  20. end
  21.  
  22. on doRollovers me
  23.   if hiliteChan <> 0 then
  24.     if not rollOver(hiliteChan) then
  25.       unhiliteSprite(me, hiliteChan)
  26.       set spriteNum to whichRoll(me)
  27.       if spriteNum = 0 then
  28.         set hiliteChan to 0
  29.       else
  30.         hiliteSprite(me, spriteNum)
  31.         ROsound(me, spriteNum)
  32.       end if
  33.     end if
  34.   else
  35.     set spriteNum to whichRoll(me)
  36.     if spriteNum <> 0 then
  37.       hiliteSprite(me, spriteNum)
  38.       ROsound(me, spriteNum)
  39.     end if
  40.   end if
  41. end
  42.  
  43. on ROsound me, whichSprite
  44.   if (whichSprite <> selectChan) and soundFlag then
  45.     set soundName to getAt(soundList, whichSprite - lowestSprite + 1)
  46.     if soundPath <> EMPTY then
  47.       sound playFile 1, soundPath & soundName
  48.     else
  49.       puppetSound(soundName)
  50.     end if
  51.     updateStage()
  52.     repeat while soundBusy(1)
  53.     end repeat
  54.     puppetSound(0)
  55.     if not rollOver(whichSprite) then
  56.       unhiliteSprite(me, hiliteChan)
  57.       set hiliteChan to 0
  58.     end if
  59.   end if
  60. end
  61.  
  62. on select me
  63.   if selectChan <> the clickOn then
  64.     if selectChan <> 0 then
  65.       deselect(me, selectChan)
  66.     end if
  67.     set selectChan to the clickOn
  68.     if selectChan = hiliteChan then
  69.       set unselectedBitmap to the castNum of sprite selectChan - 1
  70.     else
  71.       set unselectedBitmap to the castNum of sprite selectChan
  72.     end if
  73.     set hiliteChan to 0
  74.     set the castNum of sprite selectChan to unselectedBitmap + 2
  75.     return 1
  76.   else
  77.     return 0
  78.   end if
  79. end
  80.  
  81. on deselect me, whichSprite
  82.   set the castNum of sprite whichSprite to unselectedBitmap
  83. end
  84.  
  85. on hiliteSprite me, whichSprite
  86.   if whichSprite <> selectChan then
  87.     set the castNum of sprite whichSprite to the castNum of sprite whichSprite + 1
  88.     set hiliteChan to whichSprite
  89.   else
  90.     set hiliteChan to 0
  91.   end if
  92. end
  93.  
  94. on unhiliteSprite me, whichSprite
  95.   if whichSprite <> selectChan then
  96.     set the castNum of sprite whichSprite to the castNum of sprite whichSprite - 1
  97.   end if
  98. end
  99.  
  100. on whichRoll me
  101.   repeat with rollSprite = lowestSprite to highestSprite
  102.     if rollOver(rollSprite) then
  103.       exit repeat
  104.     end if
  105.   end repeat
  106.   if rollSprite > highestSprite then
  107.     return 0
  108.     exit
  109.   else
  110.     return rollSprite
  111.   end if
  112. end
  113.